"""
为自定义类型Point做哈希
只需要重载eq与hash即可
eq方法可能需要与Javaequals方法一样
"""
from typing import List

class Point:
    SEED = 13313
    MOD = 1000000000 + 7
    def __init__(self, x: int, y: int) -> None:
        self.x = x
        self.y = y
    def __eq__(self, other) -> bool:
        if isinstance(other, Point):
            return self.x == other.x and self.y == other.y
        return False
    def __hash__(self) -> int:
        return (self.x * Point.SEED + self.y)


class Solution:
    def countLatticePoints(self, circles: List[List[int]]) -> int:
        s = set()
        for x, y, r in circles:
            for i in range(x - r, x + r + 1):
                for j in range(y - r, y + r + 1):
                    p = Point(i, j)
                    if p in s: continue
                    u = x - i
                    v = y - j
                    if u * u + v * v <= r * r:
                        s.add(p)
        return len(s)